package ru.evga.billboard.document;

public class DocPartEvent
{
    public static final DocPartEvent BEFORE_SAVE = new DocPartEvent(nextCode());
    public static final DocPartEvent AFTER_SAVE = new DocPartEvent(nextCode());
    public static final DocPartEvent AFTER_LOAD = new DocPartEvent(nextCode());

    private static int eventCodeBase = 1;
    
    private int eventCode;

    protected static int nextCode()
    {
        return eventCodeBase++;
    }

    public DocPartEvent(int eventCode)
    {
        this.eventCode = eventCode;
    }

    public int getEventCode()
    {
        return eventCode;
    }

    public boolean equals(Object obj)
    {
        if (obj instanceof DocPartEvent)
        {
            if (eventCode == ((DocPartEvent)obj).getEventCode())
            {
                return true;
            }
        }
        return false;
    }

    public int hashCode()
    {
        return eventCode;
    }
}
